
#include <BReadWrite>
#include "member_BStyle.h"

using namespace BWE;

member_BStyle::member_BStyle(BStyle* style)
{
	boss = style;
	lower = 0;
	dirty = true;
}
member_BStyle::~member_BStyle()
{

}

inline char htoi(char hex)
{
	if (hex >= '0' && hex <= '9')
		return hex - '0';
	else if (hex >= 'a' && hex <= 'f')
		return hex - 'a' + 10;
	else if (hex >= 'A' && hex <= 'F')
		return hex - 'A' + 10;
	return 0;
}
inline BByte HexToByte(const char cs[2])
{
	char c0 = htoi(cs[0]);
	char c1 = htoi(cs[1]);
	return c0 * 16 + c1;
}
inline bool ConvertTextToColor(BString& text, BColor& color)
{
	if (text == "empty")
	{
		color.set(0, 0, 0, 0);
		return true;
	}
	if (text.beginsWidth('#'))
	{
		text.remove('#');
		if (text.size() == 6)
		{
			color.r() = HexToByte(text.cstr());
			color.g() = HexToByte(text.cstr() + 2);
			color.b() = HexToByte(text.cstr() + 4);
			color.a() = 255;
			return true;
		}
		if (text.size() == 8)
		{
			color.r() = HexToByte(text.cstr());
			color.g() = HexToByte(text.cstr() + 2);
			color.b() = HexToByte(text.cstr() + 4);
			color.a() = HexToByte(text.cstr() + 6);
			return true;
		}
		return false;
	}
	if (text.beginsWidth("rgb("))
	{
		int begin = text.find('(');
		text.remove(0, begin + 1);
		int end = text.find(')');
		text.remove(end, text.size());
		BStringList words;
		text.split(words, ',');
		if (words.size() == 3)
		{
			color.r() = words[0].toInt();
			color.g() = words[1].toInt();
			color.b() = words[2].toInt();
			color.a() = 255;
			return true;
		}
		return false;
	}
	if (text.beginsWidth("rgba("))
	{
		int begin = text.find('(');
		text.remove(0, begin + 1);
		int end = text.find(')');
		text.remove(end, text.size());
		BStringList words;
		text.split(words, ',');
		if (words.size() == 4)
		{
			color.r() = words[0].toInt();
			color.g() = words[1].toInt();
			color.b() = words[2].toInt();
			color.a() = words[3].toInt();
			return true;
		}
		return false;
	}
	if (text.beginsWidth("white"))
	{
		color.set(255, 255, 255);
		return true;
	}
	if (text.beginsWidth("black"))
	{
		color.set(0, 0, 0, 255);
		return true;
	}
	if (text.beginsWidth("red"))
	{
		color.set(255, 0, 0);
		return true;
	}
	if (text.beginsWidth("green"))
	{
		color.set(0, 255, 0);
		return true;
	}
	if (text.beginsWidth("blue"))
	{
		color.set(0, 0, 255);
		return true;
	}
	if (text.beginsWidth("yellow"))
	{
		color.set(255, 255, 0);
		return true;
	}
	if (text.beginsWidth("fuchsia"))
	{
		color.set(255, 0, 255);
		return true;
	}
	if (text.beginsWidth("aqua"))
	{
		color.set(0, 255, 255);
		return true;
	}
	if (text.beginsWidth("gray"))
	{
		color.set(128, 128, 128);
		return true;
	}
	if (text.beginsWidth("silver"))
	{
		color.set(192, 192, 192);
		return true;
	}
	if (text.beginsWidth("purple"))
	{
		color.set(128, 128, 128);
		return true;
	}
	if (text.beginsWidth("maroon"))
	{
		color.set(128, 0, 0);
		return true;
	}
	if (text.beginsWidth("olive"))
	{
		color.set(128, 128, 0);
		return true;
	}
	if (text.beginsWidth("navy"))
	{
		color.set(0, 0, 128);
		return true;
	}
	if (text.beginsWidth("teal"))
	{
		color.set(0, 128, 128);
		return true;
	}
	return false;
}
inline bool ConvertTextToAlign(BString& text, Align& align)
{
	align = Align_None;
	BString word;
	int pos = 0;
	while (pos < text.size())
	{
		pos = text.word(word, pos);
		if (word == "center")
			align |= Align_Center;
		else if (word == "hcenter")
			align |= Align_HCenter;
		else if (word == "vcenter")
			align |= Align_VCenter;
		else if (word == "left")
			align |= Align_Left;
		else if (word == "right")
			align |= Align_Right;
		else if (word == "top")
			align |= Align_Top;
		else if (word == "bottom")
			align |= Align_Bottom;
		else if (word == ',')
			continue;
		else
			return false;
	}
	return true;
}
inline BFont* ConvertTextToFont(BString& text)
{
	return 0;
}

inline void AnalysisColor(member_BStyle* sm, BString& sign, BString& value)
{
	if (value == "none")
	{
		if (sign == "color" || sign == "color-normal")
		{
			sm->colorMap.remove(Color_Normal);
			return;
		}
		if (sign == "color-hover")
		{
			sm->colorMap.remove(Color_Hovered);
			return;
		}
		if (sign == "color-pressed")
		{
			sm->colorMap.remove(Color_Pressed);
			return;
		}
		if (sign == "color-checked")
		{
			sm->colorMap.remove(Color_Checked);
			return;
		}
		if (sign == "color-disable")
		{
			sm->colorMap.remove(Color_Disable);
			return;
		}
		return;
	}
	BColor color;
	if (!ConvertTextToColor(value, color))
		return;
	int sem_pos = value.find(':');
	if (sem_pos < value.size())
	{
		BString name;
		value.substr(name, 0, sem_pos);
		value.remove(0, sem_pos + 1);
		sm->namedColorMap[name] = color;
		return;
	}
	if (sign == "color" || sign == "color-normal")
	{
		sm->colorMap[Color_Normal] = color;
		return;
	}
	if (sign == "color-hover")
	{
		sm->colorMap[Color_Hovered] = color;
		return;
	}
	if (sign == "color-pressed")
	{
		sm->colorMap[Color_Pressed] = color;
		return;
	}
	if (sign == "color-checked")
	{
		sm->colorMap[Color_Checked] = color;
		return;
	}
	if (sign == "color-disable")
	{
		sm->colorMap[Color_Disable] = color;
		return;
	}
}
inline void AnalysisText(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "text-color")
	{
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Text] = color;
		}
		return;
	}
	if (sign == "text-align")
	{
		Align align;
		if (ConvertTextToAlign(value, align))
		{

		}
		return;
	}
	if (sign == "text-indent")
	{
		int indent = value.toInt();
		return;
	}
}
inline void AnalysisFont(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "font")
	{
		sm->font = ConvertTextToFont(value);
		return;
	}
	if (sign == "font-family")
	{
		sm->font->setFamily(value);
		return;
	}
	if (sign == "font-size")
	{
		int size = value.toInt();
		sm->font->setSize(size);
		return;
	}
}
inline void AnalysisTitle(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "title-color")
	{
		if (value == "none")
		{
			sm->colorMap.remove(Value_Title);
			return;
		}
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Value_Title] = color;
		}
		return;
	}
	if (sign == "title-icon")
	{
		BIcon* icon = new BIcon(value);
		sm->iconMap[Icon_Title] = icon;
		return;
	}
	if (sign == "title-text-color")
	{
		if (value == "none")
		{
			sm->colorMap.remove(Color_Title_Text);
			return;
		}
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Title_Text] = color;
		}
		return;
	}
	if (sign == "title-align" || sign == "title-text-align")
	{
		Align align;
		if (ConvertTextToAlign(value, align))
		{
			sm->valueMap[Value_Title_Align] = align;
		}
		return;
	}
	if (sign == "title-space")
	{
		int space = value.toInt();
		sm->valueMap[Value_Title_Space] = space;
		return;
	}
	if (sign == "title-image")
	{
		BImage* image = Read<BImage>(value);
		sm->imageMap[Image_Title] = image;
		return;
	}
	if (sign == "title-font")
	{
		BFont* font = ConvertTextToFont(value);
		return;
	}
	if (sign == "title-button-size")
	{
		BSize size = value.toInt();
		int comma_pos = value.find(',');
		value.remove(0, comma_pos + 1);
		value.trimmed();
		if (value.size())
		{
			size.height() = value.toInt();
		}
		sm->valueMap[Value_Title_Button_Size] = size;
		return;
	}
	if (sign == "title-button-color")
	{
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Title_Button] = color;
		}
		return;
	}
	if (sign == "title-button-close-icon")
	{
		BIcon* icon = new BIcon(value);
		sm->iconMap[Icon_Title_Button_Close] = icon;
		return;
	}
	if (sign == "title-button-min-icon")
	{
		BIcon* icon = new BIcon(value);
		sm->iconMap[Icon_Title_Button_Min] = icon;
		return;
	}
	if (sign == "title-button-max-icon")
	{
		BIcon* icon = new BIcon(value);
		sm->iconMap[Icon_Title_Button_Max] = icon;
	}
}
inline void AnalysisBackground(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign.beginsWidth("background-image"))
	{
		if (value == "none")
		{
			if (sign == "background-image" || sign == "background-image-normal")
			{
				sm->imageMap.remove(Image_Background);
				return;
			}
			if (sign == "background-image-hover")
			{
				sm->imageMap.remove(Image_Background_Hovered);
				return;
			}
			if (sign == "background-image-pressed")
			{
				sm->imageMap.remove(Image_Background_Pressed);
				return;
			}
			if (sign == "background-image-checked")
			{
				sm->imageMap.remove(Image_Background_Checked);
				return;
			}
			if (sign == "background-image-disable")
			{
				sm->imageMap.remove(Image_Background_Disable);
				return;
			}
			return;
		}
		BImage* image = Read<BImage>(value);
		if (sign == "background-image" || sign == "background-image-normal")
		{
			sm->imageMap[Image_Background] = image;
			return;
		}
		if (sign == "background-image-hover")
		{
			sm->imageMap[Image_Background_Hovered] = image;
			return;
		}
		if (sign == "background-image-pressed")
		{
			sm->imageMap[Image_Background_Pressed] = image;
			return;
		}
		if (sign == "background-image-checked")
		{
			sm->imageMap[Image_Background_Checked] = image;
			return;
		}
		if (sign == "background-image-disable")
		{
			sm->imageMap[Image_Background_Disable] = image;
			return;
		}
		return;
	}
	sign.remove("-color");
	if (value == "none")
	{
		if (sign == "background" || sign == "background-normal")
		{
			sm->colorMap.remove(Color_Background);
			return;
		}
		if (sign == "background-hover")
		{
			sm->colorMap.remove(Color_Background_Hovered);
			return;
		}
		if (sign == "background-pressed")
		{
			sm->colorMap.remove(Color_Background_Pressed);
			return;
		}
		if (sign == "background-checked")
		{
			sm->colorMap.remove(Color_Background_Checked);
			return;
		}
		if (sign == "background-disable")
		{
			sm->colorMap.remove(Color_Background_Disable);
			return;
		}
		return;
	}
	BColor color;
	if (!ConvertTextToColor(value, color))
		return;
	if (sign == "background" || sign == "background-normal")
	{
		sm->colorMap[Color_Background] = color;
		return;
	}
	if (sign == "background-hover")
	{
		sm->colorMap[Color_Background_Hovered] = color;
		return;
	}
	if (sign == "background-pressed")
	{
		sm->colorMap[Color_Background_Pressed] = color;
		return;
	}
	if (sign == "background-checked")
	{
		sm->colorMap[Color_Background_Checked] = color;
		return;
	}
	if (sign == "background-disable")
	{
		sm->colorMap[Color_Background_Disable] = color;
		return;
	}
}
inline void AnalysisBorder(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "border")
	{
		int border = value.toInt();
		sm->valueMap[Value_Border] = border;
		return;
	}
	if (sign == "border-color")
	{
		if (value == "none")
		{
			sm->colorMap.remove(Value_Border);
			return;
		}
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Value_Border] = color;
		}
		return;
	}
}
inline void AnalysisPerch(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "perch")
	{
		BStringList words;
		value.split(words, ',');
		if (words.size() == 1)
		{
			int perch = words[0].toInt();
			sm->valueMap[Value_Perch_Left] = perch;
			sm->valueMap[Value_Perch_Top] = perch;
			sm->valueMap[Value_Perch_Right] = perch;
			sm->valueMap[Value_Perch_Bottom] = perch;
			return;
		}
		if (words.size() == 4)
		{
			sm->valueMap[Value_Perch_Left] = words[0].toInt();
			sm->valueMap[Value_Perch_Top] = words[1].toInt();
			sm->valueMap[Value_Perch_Right] = words[2].toInt();
			sm->valueMap[Value_Perch_Bottom] = words[3].toInt();
			return;
		}
		return;
	}
	if (sign == "perch-color")
	{
		if (value == "none")
		{
			sm->colorMap.remove(Color_Perch);
			return;
		}
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Perch] = color;
		}
		return;
	}
	if (sign == "perch-left")
	{
		int left = value.toInt();
		sm->valueMap[Value_Perch_Left] = left;
		return;
	}
	if (sign == "perch-right")
	{
		int right = value.toInt();
		sm->valueMap[Value_Perch_Right] = right;
		return;
	}
	if (sign == "perch-top")
	{
		int top = value.toInt();
		sm->valueMap[Value_Perch_Top] = top;
		return;
	}
	if (sign == "perch-bottom")
	{
		int bottom = value.toInt();
		sm->valueMap[Value_Perch_Bottom] = bottom;
		return;
	}
}
inline void AnalysisMargin(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "margin")
	{
		BStringList words;
		value.split(words, ',');
		if (words.size() == 1)
		{
			int perch = words[0].toInt();
			sm->valueMap[Value_Margin_Left] = perch;
			sm->valueMap[Value_Margin_Top] = perch;
			sm->valueMap[Value_Margin_Right] = perch;
			sm->valueMap[Value_Margin_Bottom] = perch;
			return;
		}
		if (words.size() == 4)
		{
			sm->valueMap[Value_Margin_Left] = words[0].toInt();
			sm->valueMap[Value_Margin_Top] = words[1].toInt();
			sm->valueMap[Value_Margin_Right] = words[2].toInt();
			sm->valueMap[Value_Margin_Bottom] = words[3].toInt();
			return;
		}
		return;
	}
	if (sign == "margin-color")
	{
		if (value == "none")
		{
			sm->colorMap.remove(Color_Margin);
			return;
		}
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Margin] = color;
		}
		return;
	}
	if (sign == "margin-left")
	{
		int left = value.toInt();
		sm->valueMap[Value_Margin_Left] = left;
		return;
	}
	if (sign == "margin-right")
	{
		int right = value.toInt();
		sm->valueMap[Value_Margin_Right] = right;
		return;
	}
	if (sign == "margin-top")
	{
		int bottom = value.toInt();
		sm->valueMap[Value_Margin_Bottom] = bottom;
		return;
	}
}
inline void AnalysisImage(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "image-size")
	{
		BSize size = value.toInt();
		int comma_pos = value.find(',');
		value.remove(0, comma_pos + 1);
		value.trimmed();
		if (value.size())
		{
			size.height() = value.toInt();
		}
		sm->valueMap[Value_Image_Size] = size;
		return;
	}
	int sem_pos = value.find(':');
	if (sem_pos < value.size())
	{
		BString name;
		value.substr(name, 0, sem_pos);
		value.remove(0, sem_pos + 1);
		BImage* image = Read<BImage>(value);
		if (image)
		{
			sm->namedImageMap[name] = image;
		}
	}
}
inline void AnalysisIcon(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "icon-size")
	{
		BSize size = value.toInt();
		int comma_pos = value.find(',');
		value.remove(0, comma_pos + 1);
		value.trimmed();
		if (value.size())
		{
			size.height() = value.toInt();
		}
		sm->valueMap[Value_Icon_Size] = size;
		return;
	}
	int sem_pos = value.find(':');
	if (sem_pos < value.size())
	{
		BString name;
		value.substr(name, 0, sem_pos);
		value.remove(0, sem_pos + 1);
		BIconHolder icon = new BIcon(value);
		if (!icon->empty())
		{
			sm->namedIconMap[name] = icon;
		}
	}
	else
	{
		if (value == "empty")
		{
			sm->valueMap[Value_Icon] = 0;
			return;
		}
		if (value == "none")
		{
			sm->valueMap.remove(Value_Icon);
			return;
		}
		BIconHolder icon = new BIcon(value);
		sm->valueMap[Value_Icon] = icon;
	}
}
inline void AnalysisTrans(member_BStyle* sm, BString& sign, BString& value)
{
	int sem_pos = value.find(':');
	if (sem_pos < value.size())
	{
		BString text;
		value.substr(text, 0, sem_pos);
		value.remove(0, sem_pos + 1);
		text.trimmed();
		text.lower();
		value.trimmed();
		if (text.size() && value.size())
		{
			sm->transMap[text] = value;
		}
	}
}
inline void AnalysisHandle(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign.beginsWidth("handle-color"))
	{
		if (sign == "handle-color" || sign == "handle-color-normal")
		{
			if (value == "none")
			{
				sm->colorMap.remove(Color_Handle);
				return;
			}
			BColor color;
			if (ConvertTextToColor(value, color))
			{
				sm->colorMap[Color_Handle] = color;
				return;
			}
			return;
		}
		if (sign == "handle-color-hover")
		{
			if (value == "none")
			{
				sm->colorMap.remove(Color_Handle_Hovered);
				return;
			}
			BColor color;
			if (ConvertTextToColor(value, color))
			{
				sm->colorMap[Color_Handle_Hovered] = color;
				return;
			}
			return;
		}
		if (sign == "handle-color-pressed")
		{
			if (value == "none")
			{
				sm->colorMap.remove(Color_Handle_Pressed);
				return;
			}
			BColor color;
			if (ConvertTextToColor(value, color))
			{
				sm->colorMap[Color_Handle_Pressed] = color;
				return;
			}
			return;
		}
		return;
	}
	if (sign.beginsWidth("handle-icon"))
	{
		if (sign == "handle-icon-ver")
		{
			if (value == "none")
			{
				sm->iconMap.remove(Icon_Handle_Ver);
				return;
			}
			BIcon* icon = new BIcon(value);
			sm->iconMap[Icon_Handle_Ver] = icon;
			return;
		}
		if (sign == "handle-icon-hor")
		{
			if (value == "none")
			{
				sm->iconMap.remove(Icon_Handle_Hor);
				return;
			}
			BIcon* icon = new BIcon(value);
			sm->iconMap[Icon_Handle_Hor] = icon;
			return;
		}
		return;
	}
	if (sign == "handle-size")
	{
		BSize size = value.toInt();
		int comma_pos = value.find(',');
		value.remove(0, comma_pos + 1);
		value.trimmed();
		if (value.size())
		{
			size.height() = value.toInt();
		}
		sm->valueMap[Value_Handle_Size] = size;
		return;
	}
}
inline void AnalysisSeparator(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "separator-color")
	{
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Separator] = color;
		}
		return;
	}
	if (sign == "separator-image")
	{
		BImage* image = Read<BImage>(value);
		sm->imageMap[Color_Separator] = image;
		return;
	}
	if (sign == "separator-size")
	{
		BSize size = value.toInt();
		int comma_pos = value.find(',');
		value.remove(0, comma_pos + 1);
		value.trimmed();
		if (value.size())
		{
			size.height() = value.toInt();
		}
		sm->valueMap[Value_Separator_Size] = size;
		return;
	}
}
inline void AnalysisGroupLine(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign == "group-line-color")
	{
		BColor color;
		if (ConvertTextToColor(value, color))
		{
			sm->colorMap[Color_Group_Line] = color;
		}
		return;
	}
	if (sign == "group-line-width")
	{
		int lineWidth = value.toInt();
		sm->valueMap[Value_Line_Width] = lineWidth;
		return;
	}
}
inline void AnalysisItem(member_BStyle* sm, BString& sign, BString& value)
{
	if (sign.beginsWidth("item-color"))
	{
		if (value == "none")
		{
			if (sign == "item-color" || sign == "item-color-normal")
			{
				sm->colorMap.remove(Color_Item);
				return;
			}
			if (sign == "item-color-hover")
			{
				sm->colorMap.remove(Color_Item_Hovered);
				return;
			}
			if (sign == "item-color-pressed")
			{
				sm->colorMap.remove(Color_Item_Pressed);
				return;
			}
			if (sign == "item-color-checked")
			{
				sm->colorMap.remove(Color_Item_Selected);
				return;
			}
		}
		BColor color;
		if (!ConvertTextToColor(value, color))
			return;
		if (sign == "item-color" || sign == "item-color-normal")
		{
			sm->colorMap[Color_Item] = color;
			return;
		}
		if (sign == "item-color-hover")
		{
			sm->colorMap[Color_Item_Hovered] = color;
			return;
		}
		if (sign == "item-color-pressed")
		{
			sm->colorMap[Color_Item_Pressed] = color;
			return;
		}
		if (sign == "item-color-selected")
		{
			sm->colorMap[Color_Item_Selected] = color;
			return;
		}
		return;
	}
	if (sign.beginsWidth("item-image"))
	{
		if (value == "none")
		{
			if (sign == "item-image" || sign == "item-image-normal")
			{
				sm->colorMap.remove(Image_Item);
				return;
			}
			if (sign == "item-image-hover")
			{
				sm->colorMap.remove(Image_Item_Hovered);
				return;
			}
			if (sign == "item-image-pressed")
			{
				sm->colorMap.remove(Image_Item_Pressed);
				return;
			}
			if (sign == "item-image-checked")
			{
				sm->colorMap.remove(Image_Item_Selected);
				return;
			}
		}
		BColor color;
		if (!ConvertTextToColor(value, color))
			return;
		if (sign == "item-image" || sign == "item-image-normal")
		{
			sm->colorMap[Image_Item] = color;
			return;
		}
		if (sign == "item-image-hover")
		{
			sm->colorMap[Image_Item_Hovered] = color;
			return;
		}
		if (sign == "item-image-pressed")
		{
			sm->colorMap[Image_Item_Pressed] = color;
			return;
		}
		if (sign == "item-image-checked")
		{
			sm->colorMap[Image_Item_Selected] = color;
			return;
		}
		return;
	}
}

void member_BStyle::analysis(BString& sign, BString& value)
{
	if (sign == "width")
	{
		int width = value.toInt();
		valueMap[Value_Width] = width;
		return;
	}
	if (sign == "height")
	{
		int height = value.toInt();
		valueMap[Value_Height] = height;
		return;
	}
	if (sign.beginsWidth("border"))
	{
		AnalysisBorder(this, sign, value);
		return;
	}
	if (sign.beginsWidth("perch"))
	{
		AnalysisPerch(this, sign, value);
		return;
	}
	if (sign.beginsWidth("margin"))
	{
		AnalysisMargin(this, sign, value);
		return;
	}
	if (sign.beginsWidth("color"))
	{
		AnalysisColor(this, sign, value);
		return;
	}
	if (sign.beginsWidth("title-"))
	{
		AnalysisTitle(this, sign, value);
		return;
	}
	if (sign.beginsWidth("text-"))
	{
		AnalysisText(this, sign, value);
		return;
	}
	if (sign.beginsWidth("font"))
	{
		AnalysisFont(this, sign, value);
		return;
	}
	if (sign.beginsWidth("background"))
	{
		AnalysisBackground(this, sign, value);
		return;
	}
	if (sign.beginsWidth("image"))
	{
		AnalysisImage(this, sign, value);
		return;
	}
	if (sign.beginsWidth("icon"))
	{
		AnalysisIcon(this, sign, value);
		return;
	}
	if (sign.beginsWidth("trans"))
	{
		AnalysisTrans(this, sign, value);
		return;
	}
	if (sign.beginsWidth("handle-"))
	{
		AnalysisHandle(this, sign, value);
		return;
	}
	if (sign.beginsWidth("separator"))
	{
		AnalysisSeparator(this, sign, value);
		return;
	}
	if (sign.beginsWidth("group-line"))
	{
		AnalysisGroupLine(this, sign, value);
		return;
	}
	if (sign.beginsWidth("item"))
	{
		AnalysisItem(this, sign, value);
		return;
	}
	if (sign == "space")
	{
		int space = value.toInt();
		valueMap[Value_Space] = space;
	}
}
void member_BStyle::overlap(const BStyle* style)
{
	if (style_member(style)->valueMap.size())
	{
		for (auto it = style_member(style)->valueMap.begin(); it.valid(); it++)
		{
			valueMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->colorMap.size())
	{
		for (auto it = style_member(style)->colorMap.begin(); it.valid(); it++)
		{
			colorMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->imageMap.size())
	{
		for (auto it = style_member(style)->imageMap.begin(); it.valid(); it++)
		{
			imageMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->iconMap.size())
	{
		for (auto it = style_member(style)->iconMap.begin(); it.valid(); it++)
		{
			iconMap[it.key()] = it.value();
		}
	}

	if (style_member(style)->namedImageMap.size())
	{
		for (auto it = style_member(style)->namedImageMap.begin(); it.valid(); it++)
		{
			namedImageMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->namedIconMap.size())
	{
		for (auto it = style_member(style)->namedIconMap.begin(); it.valid(); it++)
		{
			namedIconMap[it.key()] = it.value();
		}
	}
	if (style_member(style)->transMap.size())
	{
		for (auto it = style_member(style)->transMap.begin(); it.valid(); it++)
		{
			transMap[it.key()] = it.value();
		}
	}
}
const BString& member_BStyle::transWord(const BString& word) const
{
	const BStyle* style = boss;
	while (style)
	{
		auto it = style_member(style)->transMap.seek(word);
		if (it.valid())
			return *it;
		style = style_member(style)->lower;
	}
	return transMap.def();
}
